#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+10;
int a[N];
int id[N];
struct compare{
    bool operator<(int a,int b){
        return id[a] < id[b];
    }
};
struct segment_tree1{
    int ls[N*30],rs[N*30];
    int ma1[N*30],ma2[N*30];
    int pcnt;
    void push_up(int now){
        if(ma1[ls[now]] == ma1[rs[now]]){
            ma1[now] = ma1[ls[now]];
            ma2[now] = max(ma2[ls[now]],ma2[rs[now]]);
        }else if(ma1[ls[now]] > ma1[rs[now]]){
            ma1[now] = ma1[ls[now]];
            ma2[now] = max(ma2[ls[now]],ma1[rs[now]]);
        }else{
            ma1[now] = ma1[rs[now]];
            ma2[now] = max(ma2[rs[now]],ma1[ls[now]]);
        }
    }
    void update(int &now,int l,int r,int p,int v){
        if(!now){
            now = ++pcnt;
        }
        if(l == r){
            ma1[now] = v;
            ma2[now] = 0;
            return;
        }
        int mid = (l + r)/2;
        if(p <= mid){
            update(ls[now],l,mid,p,v);
        }else{
            update(rs[now],mid+1,r,p,v);
        }
        push_up(now);
    }
}sg1;
struct Trie{
    int rot;
    int ch[N*20][2];
    int pcnt;
    int rub[N*20],rubp;
    int gen(){
        int now;
        if(rubp){
            now = rub[rubp--];
        }else{
            now = ++pcnt;
        }
        return now;
    }
    __gnu_pbds::tree<int,__gnu_pbds::null_type,compare,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update> tre[N*20];
    void insert(int val,int rid){
        int now = rot;
        for(int i = 19;i >= 0;i--){
            bool p = (val>>i)&1;
            if(!ch[now][p]){
                ch[now][p] = gen();
            }
            tre[now].insert(rid);
            now = ch[now][p];
        }
        tre[now].insert(rid);
    }
    void remove(int val,int rid){
        int now = rot;
        vector<int> ps;
        for(int i = 19;i >= 0;i--){
            bool p = (val>>i)&1;
            tre[now].erase(rid);
            now = ch[now][p];
            ps.push_back(now);
        }
        tre[now].erase(rid);
        for(int i = ps.size() - 1;i >= 0;i--){
            if(tre[ps[i]].empty()){
                rub[++rubp] = ps[i];
            }
        }
    }
}tri;
int tot;
int rcnt;
struct SCT{
    int ls[N],rs[N];
    int siz[N];
    int ma1[N],ma2[N],val[N];
    bool removed[N];
    void push_up(int now)
    {
        siz[now] = siz[ls[now]] + siz[rs[now]] + (!removed[now]);
    }
    int build(vector<int> vals,int l,int r,int il,int ir){
        if(r < l){
            return 0;
        }
        int mid = (l + r)/2;
        int imid = (il + ir)/2;
        int now = vals[mid];
        id[now] = imid;
        if(l == r){
            siz[now] = 1;
            return now;    
        }
        ls[now] = build(vals,l,mid - 1,il,imid - 1);
        rs[now] = build(vals,mid + 1,r,imid + 1,ir);
        push_up(now);
    }
    void mark(int now,vector<int> &points){
        if(!now)return;
        mark(ls[now],points);
        points.push_back(now);
        mark(rs[now],points);
    }
    void mark1(int now,vector<int> &points){
        if(!now)return;
        mark(ls[now],points);
        if(!removed[now]){
            points.push_back(now);
        }
        mark(rs[now],points);
    }
    const double ALPHA = 0.75;
    bool insert(int &now,int il,int ir,int rid,int rnk,int sdp){
        int imid = (il + ir)/2;
        if(!now){
            now = rid;
            id[now] = imid;
            siz[now] = 1;
            return sdp > log(tot)/log(ALPHA);
        }
        bool f;
        if(rnk <= siz[ls[now]]){
            f = insert(ls[now],il,imid - 1,rid,rnk,sdp + 1);
        }else{
            f = insert(rs[now],imid + 1,ir,rid,rnk - siz[rs[now]] - (!removed[now]),sdp + 1);
        }
        push_up(now);
        if(f && max(siz[ls[now]],siz[rs[now]]) >= siz[now]*ALPHA){
            vector<int> p;
            mark(now,p);
            now = build(p,0,p.size() - 1,il,ir);
            return false;
        }
        return f;
    }
    void remove(int now,int rnk){
        if(rnk == siz[now] + 1){
            removed[now] = 1;
            push_up(now);
        }else if(rnk <= siz[now]){
            remove(ls[now],rnk);
            push_up(now);
        }else{
            remove(rs[now],rnk - siz[now] - (!removed[now]));
            push_up(now);
        }
    }
}sct;
int rot;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> vl(n);
    for(int i = 1;i<=n;i++){
        cin>>a[i];
        vl[i - 1] = i;
    }
    rot = sct.build(vl,0,n - 1,1,1e9);   

}